#!/bin/bash



#make error：yum install -y gcc gcc-c++


target_file=/etc/profile

home=/usr/local/nginx


mkdir -pv ${home}

rm -rf ${home}/*


#==================安装依赖：gcc gcc-c++、pcre、openssl====================================



yum install -y gcc gcc-c++

# 安装 pcre begin


cd ${home}

tar -zxvf /usr/local/software/nginx-package/pcre-8.38.tar.gz

# 获取解压文件夹名称


folder_item=`ls -l |grep pcre* |awk '{print $NF}'`

cd ${folder_item}

./configure --prefix=${home}/${folder_item}

make & make install

# 安装 pcre end




yum -y install openssl openssl-devel

# 安装 nginx begin


cd ${home}
tar -zxvf /usr/local/software/nginx-package/nginx-1.10.0.tar.gz

folder_item=`ls -l |grep nginx* |awk '{print $NF}'`

cd ${folder_item}

./configure --prefix=${home}/${folder_item}


make & make install

# 安装 nginx end



# 创建 日志目录


mkdir ./logs

# kill Nginx 进程


nginx_pid=`ps -ef | grep nginx | grep master | awk '{print $2}'`
if test -z ${nginx_pid}; then
        echo "Nginx PID 不存在"
else

        kill ${nginx_pid}
fi

# 启动 Nginx


./sbin/nginx -c ./conf/nginx.conf